package com.freshmarket.freshmarket.service.impl;

import com.freshmarket.freshmarket.entity.Pages;
import com.freshmarket.freshmarket.entity.User;
import com.freshmarket.freshmarket.dao.UserMapper;
import com.freshmarket.freshmarket.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  用户实现类
 * </p>
 *
 * @author Squirrel
 * @since 2020-09-04
 */
@Service
public class UserServiceImpl implements IUserService {

    @Resource
    private UserMapper userMapper;
    //查询总页数
    //获取每页的信息List
    //分页查询
    @Override
    public Pages selectNowPageAll(int pageIndex, int pageSize, String userName, String userPhone)throws Exception  {
        //条件分页
        List<User> users = userMapper.selectNowPageAll((pageIndex - 1) * pageSize, pageSize, userName, userPhone);
        //总条数
        int countPage = userMapper.selectCountPage(userName, userPhone);

        Pages success = Pages.success(countPage, pageIndex, pageSize, users);
        return success;
    }

}
